namespace DanceIntegration.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class FullInit : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.EventMemberKinds",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        EventMemberCount = c.Int(nullable: false),
                        CostModificator = c.Decimal(nullable: false, precision: 18, scale: 2),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.EventMembers",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        MemberKind_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.EventMemberKinds", t => t.MemberKind_ID)
                .Index(t => t.MemberKind_ID);
            
            CreateTable(
                "dbo.Persones",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        FirstName = c.String(nullable: false, maxLength: 100),
                        LastName = c.String(nullable: false, maxLength: 100),
                        MiddleName = c.String(nullable: false, maxLength: 100),
                        BirthDate = c.DateTime(nullable: false),
                        Image = c.Binary(),
                        Email = c.String(),
                        Phone = c.String(),
                        ApplicationUserID = c.String(maxLength: 128, nullable: true),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.AspNetUsers", t => t.ApplicationUserID)
                .Index(t => t.ApplicationUserID);
            
            CreateTable(
                "dbo.AspNetUsers",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        UserName = c.String(),
                        PasswordHash = c.String(),
                        SecurityStamp = c.String(),
                        CanLogin = c.Boolean(),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.AspNetUserClaims",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ClaimType = c.String(),
                        ClaimValue = c.String(),
                        User_Id = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.AspNetUsers", t => t.User_Id, cascadeDelete: true)
                .Index(t => t.User_Id);
            
            CreateTable(
                "dbo.AspNetUserLogins",
                c => new
                    {
                        UserId = c.String(nullable: false, maxLength: 128),
                        LoginProvider = c.String(nullable: false, maxLength: 128),
                        ProviderKey = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.UserId, t.LoginProvider, t.ProviderKey })
                .ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.AspNetUserRoles",
                c => new
                    {
                        UserId = c.String(nullable: false, maxLength: 128),
                        RoleId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.UserId, t.RoleId })
                .ForeignKey("dbo.AspNetRoles", t => t.RoleId, cascadeDelete: true)
                .ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
                .Index(t => t.RoleId)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.AspNetRoles",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Name = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Sections",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 200),
                        Cost = c.Decimal(nullable: false, storeType: "money"),
                        Order = c.Int(nullable: false),
                        StartTime = c.DateTime(nullable: false),
                        EndTime = c.DateTime(nullable: false),
                        PrevSectionID = c.Int(),
                        EventMember_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Sections", t => t.PrevSectionID)
                .ForeignKey("dbo.EventMembers", t => t.EventMember_ID)
                .Index(t => t.PrevSectionID)
                .Index(t => t.EventMember_ID);
            
            CreateTable(
                "dbo.Events",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        StartTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.PersonEventMembers",
                c => new
                    {
                        Person_ID = c.Int(nullable: false),
                        EventMember_ID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Person_ID, t.EventMember_ID })
                .ForeignKey("dbo.Persones", t => t.Person_ID, cascadeDelete: true)
                .ForeignKey("dbo.EventMembers", t => t.EventMember_ID, cascadeDelete: true)
                .Index(t => t.Person_ID)
                .Index(t => t.EventMember_ID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Sections", "EventMember_ID", "dbo.EventMembers");
            DropForeignKey("dbo.Sections", "PrevSectionID", "dbo.Sections");
            DropForeignKey("dbo.Persones", "ApplicationUserID", "dbo.AspNetUsers");
            DropForeignKey("dbo.AspNetUserClaims", "User_Id", "dbo.AspNetUsers");
            DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles");
            DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.PersonEventMembers", "EventMember_ID", "dbo.EventMembers");
            DropForeignKey("dbo.PersonEventMembers", "Person_ID", "dbo.Persones");
            DropForeignKey("dbo.EventMembers", "MemberKind_ID", "dbo.EventMemberKinds");
            DropIndex("dbo.Sections", new[] { "EventMember_ID" });
            DropIndex("dbo.Sections", new[] { "PrevSectionID" });
            DropIndex("dbo.Persones", new[] { "ApplicationUserID" });
            DropIndex("dbo.AspNetUserClaims", new[] { "User_Id" });
            DropIndex("dbo.AspNetUserRoles", new[] { "UserId" });
            DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" });
            DropIndex("dbo.AspNetUserLogins", new[] { "UserId" });
            DropIndex("dbo.PersonEventMembers", new[] { "EventMember_ID" });
            DropIndex("dbo.PersonEventMembers", new[] { "Person_ID" });
            DropIndex("dbo.EventMembers", new[] { "MemberKind_ID" });
            DropTable("dbo.PersonEventMembers");
            DropTable("dbo.Events");
            DropTable("dbo.Sections");
            DropTable("dbo.AspNetRoles");
            DropTable("dbo.AspNetUserRoles");
            DropTable("dbo.AspNetUserLogins");
            DropTable("dbo.AspNetUserClaims");
            DropTable("dbo.AspNetUsers");
            DropTable("dbo.Persones");
            DropTable("dbo.EventMembers");
            DropTable("dbo.EventMemberKinds");
        }
    }
}
